package cn.cloud.project.openfeign.api.configuration;

import cn.cloud.project.openfeign.config.CustomFeignInterceptor;
import cn.cloud.project.openfeign.config.SimpleRetryer;
import feign.Logger;
import feign.Request;
import feign.RequestInterceptor;
import feign.Retryer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @author: cql
 * @date: 2024/11/5
 * @description: 单独配置feign客户端
 */
@Configuration
public class ProviderApiConfiguration {

    @Bean
    public Logger.Level logger() {
        return Logger.Level.FULL;
    }

    @Bean
    public Request.Options options() {
        return new Request.Options(5, TimeUnit.SECONDS, 5, TimeUnit.SECONDS, true);
    }

    @Bean
    public Retryer retryer() {
        return new SimpleRetryer();
    }

    @Bean
    public RequestInterceptor requestInterceptor(){
        return new CustomFeignInterceptor();
    }

}
